//
//  BeeNewsTableCell.m
//  BeeWeb
//
//  Created by Jimmy on 29/10/2010.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//




#import "MasterTableCell.h"
#import "JSON.h"
#import "AppDelegate.h"
#import "Config.h"
#import <QuartzCore/QuartzCore.h>



@implementation MasterTableCell
@synthesize updateDate,orderId,totalMoney,applyer,appleReason;
@synthesize imageView;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
        self.backgroundColor=[UIColor  clearColor];
        self.orderId=[self  customLabel:CGRectMake(10, 5, 250, 25)];
        self.orderId.font=[UIFont boldSystemFontOfSize:FONTSIZE];
        self.updateDate=[self  customLabel:CGRectMake(260, 5, 250, 25)];
        
        self.totalMoney=[self  customLabel:CGRectMake(10, 30, 250, 25)];
        self.totalMoney.textColor=[UIColor  redColor];
        self.applyer=[self  customLabel:CGRectMake(260, 30, 250, 25)];
        self.applyer.textColor=[UIColor colorWithRed:4/255.0 green:168/255.0 blue:9/255.0 alpha:1.0];
        
        
         self.appleReason=[self  customLabel:CGRectMake(10, 55,self.frame.size.width-20, 25)];
        
        [self addSubview:self.updateDate];
        [self addSubview:self.totalMoney];
        [self addSubview:self.appleReason];
        [self addSubview:self.orderId];
        [self addSubview:self.applyer];
        
        UIImageView *_imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 69, self.frame.size.width, 1)];
        self.imageView.image=[UIImage imageNamed:@"split.png"];
        self.imageView=_imageView;
         [self addSubview:self.imageView];
        [_imageView release];
        
        //self.selectionStyle = UITableViewCellSelectionStyleGray;
    }
    return self; 
}

-(void) showData:(NSDictionary*)detailItem{
    NSString *updateDateStr=[[detailItem  objectForKey:@"提单时间"] objectForKey:@"text"];
    self.updateDate.text=[[updateDateStr  componentsSeparatedByString:@"T"]objectAtIndex:0];
    self.orderId.text=[[detailItem  objectForKey:@"单号"] objectForKey:@"text"];
    self.totalMoney.text=[NSString  stringWithFormat:@"金额:%@",[[detailItem  objectForKey:@"金额"] objectForKey:@"text"]];
    self.applyer.text=[NSString  stringWithFormat:@"申请人:%@",[[detailItem  objectForKey:@"申请人"] objectForKey:@"text"]];
    self.appleReason.text=[NSString  stringWithFormat:@"事由:%@",[[detailItem  objectForKey:@"事由"] objectForKey:@"text"]];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(UILabel*) customLabel:(CGRect) frame{
    UILabel *_label=[[UILabel alloc] initWithFrame:frame];
    _label.lineBreakMode = UILineBreakModeTailTruncation;
    _label.numberOfLines = 1;
    _label.opaque = NO; // 选中Opaque表示视图后面的任何内容都不应该绘制
    _label.backgroundColor = [UIColor clearColor];
    _label.font=[UIFont fontWithName:FONTFAMILY size:FONTSIZE];
    _label.textColor=[UIColor  blackColor];
     return [_label  autorelease];
} 
- (void)dealloc {
    [updateDate  release];
    [orderId  release];
    [totalMoney  release];
    [applyer  release];
    [appleReason  release];
    [imageView  release];
    [super dealloc];
}


@end
